//
//  User.swift
//  FM
//
//  Created by x on 2017/8/30.
//  Copyright © 2017年 HLB. All rights reserved.
//

import UIKit

class User: NSObject {
    
    /// 用户id
    var id:String?
    
    /// 用户名称
    var username:String?
    
    /// 用户昵称
    var nickname:String?
    
    /// 用户手机号
    var phone:String?
    
    /// 用户头像地址
    var avatar:String? {
        didSet {
            guard avatar == nil else {
                avaterURL = URL(string: avatar!)
                return
            }
        }
    }
    
    /// 保存用户头像地址
    var avaterURL:URL?
    
    
    init(dic:[String: AnyObject]) {
        super.init()
        setValuesForKeys(dic)
    }
    
    override func setValue(_ value: Any?, forUndefinedKey key: String) {
        print("user===key=======\(key)")
    }
    
    /// 打印model数据模型
    override var description: String {
        let keys = ["id","username","nickname","phone","avatar"]
        let dic = dictionaryWithValues(forKeys: keys)
        
        return "\(dic)"
    }
}
